package com.itheima.contact.web;

import com.itheima.contact.domain.User;
import com.itheima.contact.service.UserService;
import com.itheima.contact.utils.CommonUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author ${Azer}
 * @LOVE,,,
 * @Date 2021/9/19 17:40
 */
//修改用户
@WebServlet("/updateUserById")
public class UpdateUserById extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //获取用户更新页面提交的数据,并封装成User对象
        User user = CommonUtils.CommonPopulate(User.class, request);

        UserService userService=new UserService();

        userService.updateUserById(user);

        response.sendRedirect("/update_ok.jsp");


    }
}
